package com.jt;

import com.jt.mapper.DogMapper;
import com.jt.mapper.UserMapper2;
import com.jt.pojo.Dog;
import com.jt.pojo.User;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@SpringBootTest
class MybatisDemo1ApplicationTests2 {

    @Autowired
    private UserMapper2 userMapper2;
    @Autowired
    private DogMapper dogMapper;

    @Test
    public void testDemo1(){
        User user = new User();
        user.setAge(18).setSex("女");    //动态变化的数据
        List<User> userList = userMapper2.findUserList(user);
        System.out.println(userList);
    }
    //执行动态的更新操作
    //根据对中不为null的元素，充当set条件
    @Test
    public void testDemo2(){
        User user = new User();
        user.setId(235).setName("王二麻子").setAge(25).setSex("男");
        userMapper2.updateUser(user);
        System.out.println("更新成功");
    }
    @Test
    public void testDemo3(){
        User user = new User();
        user.setName(null).setAge(18).setSex("女");
        List<User> userList = userMapper2.findUserByNS(user);
        System.out.println(userList);
    }
    @Test
    public void testDog1(){
        List<Dog> dogList = dogMapper.findAll();
        System.out.println(dogList);
    }


}
